package siddur.traktask.util;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class ImageUtil {
	
	private static int width = 250;
	private static int height = 176;
	public static final String IMAGE_TYPE = "jpg";
	
	public static void resize(File src) throws IOException{
		BufferedImage bi = ImageIO.read(src);
		Image i = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH);
		BufferedImage newImage = new BufferedImage(width, height, bi.getType());
		Graphics2D g = newImage.createGraphics();
		g.drawImage(i, null, null);
		
		
		File f = new File(src.getParentFile(), "s_" + src.getName());
		ImageIO.write(newImage, IMAGE_TYPE, f);
	}
	
	
	public static void main(String[] args) throws IOException {
		String base = "C:\\IDE\\eclipsEE\\fileserver\\images\\1";
		File dir = new File(base);
		for (File d : dir.listFiles()) {
			for (File i : d.listFiles()) {
				resize(i);
			}
		}
	}
}
